home *** CD-ROM | disk | FTP | other *** search
- package java.util;
-
- import java.io.Serializable;
- import java.security.AccessController;
- import java.util.spi.CurrencyNameProvider;
- import sun.util.LocaleServiceProviderPool;
- import sun.util.resources.LocaleData;
- import sun.util.resources.OpenListResourceBundle;
-
- public final class Currency implements Serializable {
- private static final long serialVersionUID = -158308464356906721L;
- private final String currencyCode;
- private final transient int defaultFractionDigits;
- private static HashMap instances = new HashMap(7);
- static String mainTable;
- static long[] scCutOverTimes;
- static String[] scOldCurrencies;
- static String[] scNewCurrencies;
- static int[] scOldCurrenciesDFD;
- static int[] scNewCurrenciesDFD;
- static String otherCurrencies;
- static int[] otherCurrenciesDFD;
- private static final int A_TO_Z = 26;
- private static final int INVALID_COUNTRY_ENTRY = 127;
- private static final int COUNTRY_WITHOUT_CURRENCY_ENTRY = 128;
- private static final int SIMPLE_CASE_COUNTRY_MASK = 0;
- private static final int SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK = 31;
- private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK = 96;
- private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT = 5;
- private static final int SPECIAL_CASE_COUNTRY_MASK = 128;
- private static final int SPECIAL_CASE_COUNTRY_INDEX_MASK = 31;
- private static final int SPECIAL_CASE_COUNTRY_INDEX_DELTA = 1;
- private static final int COUNTRY_TYPE_MASK = 128;
-
- private Currency(String var1, int var2) {
- this.currencyCode = var1;
- this.defaultFractionDigits = var2;
- }
-
- public static Currency getInstance(String var0) {
- return getInstance(var0, Integer.MIN_VALUE);
- }
-
- private static Currency getInstance(String var0, int var1) {
- synchronized(instances) {
- Currency var3 = (Currency)instances.get(var0);
- if (var3 != null) {
- return var3;
- } else {
- if (var1 == Integer.MIN_VALUE) {
- if (var0.length() != 3) {
- throw new IllegalArgumentException();
- }
-
- char var4 = var0.charAt(0);
- char var5 = var0.charAt(1);
- int var6 = getMainTableEntry(var4, var5);
- if ((var6 & 128) == 0 && var6 != 127 && var0.charAt(2) - 65 == (var6 & 31)) {
- var1 = (var6 & 96) >> 5;
- } else {
- if (var0.charAt(2) == '-') {
- throw new IllegalArgumentException();
- }
-
- int var7 = otherCurrencies.indexOf(var0);
- if (var7 == -1) {
- throw new IllegalArgumentException();
- }
-
- var1 = otherCurrenciesDFD[var7 / 4];
- }
- }
-
- var3 = new Currency(var0, var1);
- instances.put(var0, var3);
- return var3;
- }
- }
- }
-
- public static Currency getInstance(Locale var0) {
- String var1 = var0.getCountry();
- if (var1 == null) {
- throw new NullPointerException();
- } else if (var1.length() != 2) {
- throw new IllegalArgumentException();
- } else {
- char var2 = var1.charAt(0);
- char var3 = var1.charAt(1);
- int var4 = getMainTableEntry(var2, var3);
- if ((var4 & 128) == 0 && var4 != 127) {
- char var8 = (char)((var4 & 31) + 65);
- int var6 = (var4 & 96) >> 5;
- StringBuffer var7 = new StringBuffer(var1);
- var7.append(var8);
- return getInstance(var7.toString(), var6);
- } else if (var4 == 127) {
- throw new IllegalArgumentException();
- } else if (var4 == 128) {
- return null;
- } else {
- int var5 = (var4 & 31) - 1;
- return scCutOverTimes[var5] != Long.MAX_VALUE && System.currentTimeMillis() >= scCutOverTimes[var5] ? getInstance(scNewCurrencies[var5], scNewCurrenciesDFD[var5]) : getInstance(scOldCurrencies[var5], scOldCurrenciesDFD[var5]);
- }
- }
- }
-
- public String getCurrencyCode() {
- return this.currencyCode;
- }
-
- public String getSymbol() {
- return this.getSymbol(Locale.getDefault());
- }
-
- public String getSymbol(Locale var1) {
- try {
- LocaleServiceProviderPool var2 = LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
- if (var2.hasProviders()) {
- String var3 = (String)var2.getLocalizedObject(java.util.Currency.CurrencyNameGetter.access$000(), var1, (OpenListResourceBundle)null, this.currencyCode, new Object[0]);
- if (var3 != null) {
- return var3;
- }
- }
-
- ResourceBundle var5 = LocaleData.getCurrencyNames(var1);
- return var5.getString(this.currencyCode);
- } catch (MissingResourceException var4) {
- return this.currencyCode;
- }
- }
-
- public int getDefaultFractionDigits() {
- return this.defaultFractionDigits;
- }
-
- public String toString() {
- return this.currencyCode;
- }
-
- private Object readResolve() {
- return getInstance(this.currencyCode);
- }
-
- private static int getMainTableEntry(char var0, char var1) {
- if (var0 >= 'A' && var0 <= 'Z' && var1 >= 'A' && var1 <= 'Z') {
- return mainTable.charAt((var0 - 65) * 26 + (var1 - 65));
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- static {
- AccessController.doPrivileged(new 1());
- }
- }
-